home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6395 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: news.mistral.co.uk!usenet
  2. From: mikebarnard@mistral.co.uk (Mike Barnard)
  3. Newsgroups: comp.lang.c
  4. Subject: Please Please Help! - pointer notation
  5. Date: Sat, 24 Feb 1996 16:28:14 GMT
  6. Organization: Mistral Internet (Brighton)
  7. Message-ID: <4gnlv9$1fh@news.mistral.co.uk>
  8. NNTP-Posting-Host: 194.73.212.177
  9. X-Newsreader: Forte Free Agent 1.0.82
  10.  
  11. Hi.
  12.  
  13. I'm reposting this as I've had no replies and I'm still without the
  14. information.
  15.  
  16. I've read my C book. I've gotten th C FAQ. I've read the file
  17. "ptrtutor.txt" a tutorial on pointers. But I havn't seen explained the
  18. following. Can you help?
  19.  
  20. Sometimes when prototyping a function the function name is pre-fixed
  21. by an asterisk. Why? What does it mean? This is a quote from the
  22. pointer tutorial text by Ted Jensen...
  23.  
  24.  
  25.  
  26.  
  27. +++++++++++++++++++++++++++++++++++++++++++++
  28.  
  29. "    Of course, what the above program illustrates is a simple way
  30. of copying a string.  After playing with the above until you have
  31. a good understanding of what is happening, we can proceed to
  32. creating our own replacement for the standard strcpy() that comes
  33. with C.  It might look like:
  34.  
  35.    char *my_strcpy(char *destination, char *source)
  36.    {
  37.         char *p = destination
  38.         while (*source != '\0')
  39.         {
  40.            *p++ = *source++;
  41.         }
  42.         *p = '\0';
  43.         return destination.
  44.    }
  45.  
  46.     In this case, I have followed the practice used in the
  47. standard routine of returning a pointer to the destination."
  48.  
  49. +++++++++++++++++++++++++++++++++++++++++++++
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56. I can't find an explanation fro the asterisk BEFORE THE FUNCTION NAME.
  57.  
  58.  
  59.  
  60. Putting an asterisk before a variable name declares it as a pointer
  61. variable. Putting one before the variable in use means you want to
  62. access the data pointed to. Why is there sometimes an asterisk AFTER a
  63. variable?
  64.  
  65. (And I can't find a quote at the moment...)
  66.  
  67. All hint's will be of GREAT use. Thanks.
  68.  
  69.  
  70. ---
  71. Mic.
  72. From windy and damp Worthing; England.
  73. mikebarnard@mistral.co.uk
  74.  
  75. (I just lost 4 fence panels to the wind here! The cost of
  76. replacing them could have bought me a new windows compiler!)
  77.  
  78.